<?php

/*
 * Fresns (https://fresns.org)
 * Copyright (C) 2021-Present Jarvis Tang
 * Released under the Apache-2.0 License.
 */

namespace Fresns\PluginManager\Support\Composer;

use Fresns\PluginManager\Exceptions\ComposerException;

class ComposerUpdate extends Composer
{
    public function getUpdateCommand()
    {
        return "composer update plugins";
    }

    public function beforeRun(): void
    {
    }

    public function run()
    {
        $this->beforeRun();

        // 通过更新不存在的包，触发 Composer Merge Plugin 安装项目中更新或新创建的子级 composer.json 文件的依赖项
        passthru($this->getUpdateCommand());

        $this->afterRun();
    }

    public function afterRun(): void
    {
        // after update
    }
}
